/*项目接口*/
import request from "./request";

/**
 * 分页获取博客列表
 * @param pageSize 页面大小
 * @param currentPage 当前页数
 * @returns {AxiosPromise}
 */
export const getBlogList = (pageSize, currentPage)=>{
    return request({
        url: '/getBlogList',
        method: 'get',
        params:{
            pageSize: pageSize,
            currentPage: currentPage
        }
    })
}

/**
 * 按标签筛选博客
 * @param pageSize
 * @param currentPage
 * @param tagName
 * @returns {AxiosPromise}
 */
export const getBlogListByTag = (pageSize, currentPage, tagName)=>{
    return request({
        url: '/getBlogListByTag',
        method: 'get',
        params:{
            pageSize: pageSize,
            currentPage: currentPage,
            tagName: tagName
        }
    })
}

/**
 * 根据关键词搜索博客
 * @param keyWord
 * @returns {AxiosPromise}
 */
export const searchBlog = (keyWord)=>{
    return request({
        url: "/searchBlog",
        method: 'get',
        params:{
            keyWord: keyWord
        }
    })
}

/**
 * 根据md文件路径获取博客详情
 * @param mdUrl
 * @returns {AxiosPromise}
 */
export const getBlogDetail = (id)=>{
    return request({
        url: "/getBlogDetail",
        method: 'get',
        params:{
            id: id
        }
    })
}

/**
 * 上传图片
 * @param formdata
 * @returns {AxiosPromise}
 */
export const addImg = (formdata)=>{
    return request({
        url: "/uploadImg",
        method: 'post',
        data: formdata
    })
}

/**
 * 发表博客
 * @param blog
 * @returns {AxiosPromise}
 */
export const postBlog  = (blog)=>{
    return request({
        url: '/postBlog',
        method: 'post',
        data: blog
    })
}

/**
 * 删除指定id博客
 * @param id
 * @returns {AxiosPromise}
 */
export const deleteBlog = (id)=>{
    return request({
        url: "/deleteBlog",
        method: "post",
        data: {
            id: id
        }
    })
}

/**
 * 更新博客内容
 * @param blog
 * @returns {AxiosPromise}
 */
export const updateBlog = (blog)=>{
    return request({
        url: '/updateBlog',
        method: 'post',
        data:blog
    })
}

export const login = (account, passWord)=>{
    return request({
        url: '/login',
        method: 'post',
        data:{
            account: account,
            passWord: passWord
        }
    })
}

